package com.fly.trading.runner;

import java.time.Duration;
import java.util.Arrays;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import com.fly.trading.dao.TradingUserRepository;
import com.fly.trading.entity.TradingUser;

@Component
public class UsersCommandLineRunner implements CommandLineRunner
{
    @Autowired
    TradingUserRepository repository;
    
    @Override
    public void run(String... strings)
        throws Exception
    {
        List<TradingUser> users = Arrays.asList(new TradingUser("sdeleuze", "Sebastien Deleuze"),
            new TradingUser("snicoll", "Stephane Nicoll"),
            new TradingUser("rstoyanchev", "Rossen Stoyanchev"),
            new TradingUser("poutsma", "Arjen Poutsma"),
            new TradingUser("smaldini", "Stephane Maldini"),
            new TradingUser("simonbasle", "Simon Basle"),
            new TradingUser("violetagg", "Violeta Georgieva"),
            new TradingUser("bclozel", "Brian Clozel"));
        repository.insert(users).blockLast(Duration.ofSeconds(3));
    }
}
